using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class HoaDonNhapHangMap : EntityTypeConfiguration<HoaDonNhapHang>
    {
        public HoaDonNhapHangMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.SoHoaDon)
                .HasMaxLength(50);

            this.Property(t => t.KhuyenMai2)
                .HasMaxLength(50);

            this.Property(t => t.KhuyenMai1)
                .HasMaxLength(50);

            this.Property(t => t.TongTienHoaDon)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("HoaDonNhapHang");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SoHoaDon).HasColumnName("SoHoaDon");
            this.Property(t => t.NgayLapHoaDon).HasColumnName("NgayLapHoaDon");
            this.Property(t => t.NgayNhapHoaDon).HasColumnName("NgayNhapHoaDon");
            this.Property(t => t.KhuyenMai2).HasColumnName("KhuyenMai2");
            this.Property(t => t.KhuyenMai1).HasColumnName("KhuyenMai1");
            this.Property(t => t.VAT).HasColumnName("VAT");
            this.Property(t => t.TongTienHoaDon).HasColumnName("TongTienHoaDon");
            this.Property(t => t.NhaThuocId).HasColumnName("NhaThuocId");
            this.Property(t => t.UserGuiDonDatHangId).HasColumnName("UserGuiDonDatHangId");
            this.Property(t => t.UserNhanDonDatHangId).HasColumnName("UserNhanDonDatHangId");
            this.Property(t => t.TrangThai).HasColumnName("TrangThai");

            // Relationships
            this.HasOptional(t => t.NhaThuoc)
                .WithMany(t => t.HoaDonNhapHangs)
                .HasForeignKey(d => d.NhaThuocId);

        }
    }
}
